
#include <BFont>
#include <BWidget>
#include "member_BSwitcher.h"
#include "member_BButton.h"

using namespace BWE;

member_BSwitcher::member_BSwitcher(BSwitcher* switcher)
{
	boss = switcher;
	space = 2;
	pressed = false;
	hoveredIndex = -1;
	checkedButton = 0;
	orientation = Orientation_Vertical;
	align = Align_Center;
}
member_BSwitcher::~member_BSwitcher()
{

}

void member_BSwitcher::slotButtonChecked(BObject* object, const BValue& value)
{
	BButton* button = (BButton*)object;
	for (int i = 0; i < items.size(); i++)
	{
		SwitchItem& item = items[i];
		if (item.button != button && button_member(item.button)->checked)
		{
			button_member(item.button)->checked = false;
			item.button->fresh();
		}
	}
	checkedButton = 0;
	if (button->checked())
	{
		checkedButton = button;
	}
	boss->emit(Signal_Switched, checkedButton);
}
